package com.winning.joiner.magiccube.tool.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * 数据库和java字段映射
 * 
 * @author joiner
 */
public class ColumnFieldMap
{
    /** 状态编码转换 */
    public static Map<String, String> javaTypeMap = new HashMap<String, String>();
    public static Map<String, String> javaToJdbcTypeMap = new HashMap<String, String>();
    

    static
    {
        initJavaTypeMap();
        initjava2JdbcTypeMap();
    }

    /**
     * 返回状态映射
     */
    private static void initJavaTypeMap()
    {
    	/**
    	 * mysql 数据类型
    	 */
        javaTypeMap.put("tinyint", "Byte");
        javaTypeMap.put("smallint", "Integer");
        javaTypeMap.put("mediumint", "Integer");
        javaTypeMap.put("int", "Integer");
        javaTypeMap.put("integer", "integer");
        javaTypeMap.put("bigint", "Long");
        javaTypeMap.put("float", "Float");
        javaTypeMap.put("double", "Double");
        javaTypeMap.put("decimal", "BigDecimal");
        javaTypeMap.put("bit", "Boolean");
        javaTypeMap.put("char", "String");
        javaTypeMap.put("varchar", "String");
        javaTypeMap.put("tinytext", "String");
        javaTypeMap.put("text", "String");
        javaTypeMap.put("mediumtext", "String");
        javaTypeMap.put("longtext", "String");
        javaTypeMap.put("date", "Date");
        javaTypeMap.put("datetime", "Date");
        javaTypeMap.put("timestamp", "Date");
        /**
         * oracle 数据
         */
        javaTypeMap.put("VARCHAR", "String");
        javaTypeMap.put("VARCHAR2", "String");
        javaTypeMap.put("CHAR", "String");
        javaTypeMap.put("LONGVARCHAR", "String");
        javaTypeMap.put("NUMERIC", "BigDecimal");
        javaTypeMap.put("DECIMAL", "BigDecimal");
        javaTypeMap.put("BIT", "boolean");
        javaTypeMap.put("BOOLEAN", "boolean");
        javaTypeMap.put("TINYINT", "byte");
        javaTypeMap.put("SMALLINT", "short");
        javaTypeMap.put("INTEGER", "Integer");
        javaTypeMap.put("BIGINT", "Long");
        javaTypeMap.put("FLOAT", "double");
        javaTypeMap.put("DOUBLE", "double");
        javaTypeMap.put("DATE", "Date");
        javaTypeMap.put("TIME", "Time");
        javaTypeMap.put("TIMESTAMP", "Timestamp");
        javaTypeMap.put("BLOB", "Blob");
        javaTypeMap.put("CLOB", "Clob");
        javaTypeMap.put("NUMBER", "Long");
        
        
        
    }
    /**
     * 通过javaType获取jdbcType
     */
    private static void initjava2JdbcTypeMap(){
    	javaToJdbcTypeMap.put("Integer", "INTEGER");
    	javaToJdbcTypeMap.put("int", "INTEGER");
    	javaToJdbcTypeMap.put("integer", "INTEGER");
    	javaToJdbcTypeMap.put("Long", "BIGINT");
    	javaToJdbcTypeMap.put("long", "BIGINT");
    	javaToJdbcTypeMap.put("Float", "REAL");
    	javaToJdbcTypeMap.put("float", "REAL");
    	javaToJdbcTypeMap.put("Double", "DOUBLE");
    	javaToJdbcTypeMap.put("double", "DOUBLE");
    	javaToJdbcTypeMap.put("BigDecimal", "DECIMAL");
    	javaToJdbcTypeMap.put("Boolean", "INTEGER");
    	javaToJdbcTypeMap.put("boolean", "INTEGER");
    	javaToJdbcTypeMap.put("Date", "INTEGER");
    	javaToJdbcTypeMap.put("String", "VARCHAR");
    	javaToJdbcTypeMap.put("Byte", "TINYINT");
    	javaToJdbcTypeMap.put("byte", "TINYINT");
    	javaToJdbcTypeMap.put("short", "SMALLINT");
    	javaToJdbcTypeMap.put("Clob", "CLOB");
    	javaToJdbcTypeMap.put("Blob", "BLOB");
    	
    	
    }
}
